using System;
using System.Collections.Generic;
using System.Text;
using Attach;

namespace Attach.Internal
{
    public class Stub : IBehavior
    {
        private ContinueMethod continueMethod;
        private Results _results = new Results();
        private Return _action;

        public Stub(Return action)
        {
            _action = action;
        }

        public ContinueMethod Continue
        {
            set { continueMethod = value; }
        }

        public object Run(object[] parameters)
        {
            RecordCall(parameters);
            return _action.GetReturnValue(parameters);
        }

        private void RecordCall(object[] parameters)
        {
            _results.WasCalled = true;
            _results.CallCount++;
            _results.Parameters = parameters;
            CallRecording callRecording = new CallRecording();
            callRecording.Parameters = parameters;
            _results.History.Add(callRecording);
        }

        public Results Results
        {
            get { return _results; }
        }
    }
}
